package com.android.youwenchuang.ui.activity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.android.youwenchuang.R;
import com.android.youwenchuang.base.BaseActivity;
import com.android.youwenchuang.bean.CarBean;
import com.android.youwenchuang.bean.OrderBean;
import com.android.youwenchuang.databinding.ActivityCarBinding;
import com.android.youwenchuang.databinding.ActivityOrderBinding;
import com.android.youwenchuang.presenter.CarPresenter;
import com.android.youwenchuang.presenter.OrderPresenter;
import com.android.youwenchuang.ui.adapter.CarAdapter;
import com.android.youwenchuang.ui.adapter.OrderAdapter;
import com.blankj.utilcode.util.ThreadUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;

import java.util.List;

/**
 * 订单
 */
public class OrderActivity extends BaseActivity {

    private ActivityOrderBinding viewBinding;

    private OrderPresenter presenter = new OrderPresenter();

    private OrderAdapter adapter = new OrderAdapter();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        viewBinding = ActivityOrderBinding.inflate(LayoutInflater.from(this));
        setContentView(viewBinding.getRoot());
        initTitleBar();

        viewBinding.rvList.setLayoutManager(new LinearLayoutManager(this));
        viewBinding.rvList.setAdapter(adapter);
        ThreadUtils.executeByIo(new ThreadUtils.SimpleTask<List<OrderBean>>() {
            @Override
            public List<OrderBean> doInBackground() throws Throwable {
                return presenter.getList();
            }

            @Override
            public void onSuccess(List<OrderBean> result) {
                adapter.setNewInstance(result);
            }
        });
    }

}
